<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>不含特殊楼层的最大连续楼层数</title>
</head>
<body>
  <script>
    function fn(bottom, top, special) {
      special.sort((a, b) => a - b)
      let ans = 0
      for (let i = 0; i < special.length; i++) {
        ans = Math.max(ans, special[i] - bottom)
        bottom = special[i] + 1
      }
      if (special[special.length - 1] !== top) {
        ans = Math.max(ans, top - bottom + 1)
      }
      return ans
    }
    console.log(fn(2, 9, [4, 6]))
  </script>
</body>
</html>